var api = require('../../../utils/api.js')
var $ = require('../../../utils/util.js')
var regeneratorRuntime = require('../../../utils/runtime.js')
var app = getApp()
var Store = app.Store 
Page({
  data: {
    signFile: {},
    form:{}, // redux传过来的参数
  },
  saveToImageEvent(e){
    let that = this;
    $.uploadFile(that.data.form.key=='workSign'?api.workTicket.signUpload:api.operateTicket.signUpload, e.detail, 'image',{ticketNumber:this.data.ticketNumber}).then((res) => {
      Store.dispatch({
        type: 'SET_FROM',
        form: { 
          key: that.data.form.key, // 后台要的更改字段 
          selected:res.msg,
        },
      })
      $.linkurl('', 'back')
    })
    // wx.uploadFile({
    //   url:that.data.form.key=='workSign'?api.workTicket.signUpload:api.operateTicket.signUpload,
    //   filePath: e.detail,
    //   name: 'image',
    //   formData:{'ticketNumber':that.data.ticketNumber},
    //   header: {
    //     'dataType': "json",
    //     'Content-Type': 'multipart/form-data',
    //     'Authorization': 'Bearer ' + wx.getStorageSync('token'),
    //   },
    //   success (res){
    //     Store.dispatch({
    //       type: 'SET_FROM',
    //       form: { 
    //         key: that.data.form.key, // 后台要的更改字段 
    //         selected:JSON.parse(res.data).msg,
    //       },
    //     })
    //     $.linkurl('', 'back')
    //   }
    // })
    
  },
  onLoad(options) {
    this.setData({
      form: Store.getState().formInfor.form,
      ticketNumber:options.ticketNumber
    }) 
  }, 
  onReady() {
  
  },
  onShow() {
 
  },
  onHide() {
 
  },
  onUnload() {
 
  },
  onShareAppMessage() {
    return {
      title: '',
    };
  },
});